package com.java.comprehensive.arithmetic.leecode.easy;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: comprehensive-service
 *
 * @description: 数组：两数之和
 *
 * @author: 窦绍飞
 *
 * @create: 2021-12-07 15:34
 **/
public class LeetCode_01 {
	public int[] twoSum(int[] nums, int target) {
		Map<Integer, String> map = new HashMap<Integer, String>();
		for (int i = 0; i < nums.length; i++) {
			Integer temp = target - nums[i];
			if (map.containsKey(temp)) {
				return new int[] { i, Integer.parseInt(map.get(temp)) };
			}
			map.put(nums[i], String.valueOf(i));
		}
		return null;
	}

	static class Solution {
		public int[] twoSum(int[] nums, int target) {
			Map<Integer, Integer> map = new HashMap<>();
			int[] result = new int[2];
			for (int i = 0; i < nums.length; i++) {
				int num = nums[i];
				int n = target - num;
				if (map.containsKey(n)) {
					result[0] = i;
					result[1] = map.get(n);
				} else {
					map.put(num, i);
				}
			}
			return result;
		}
	}

	public static void main(String[] args) {
		int a = 15;
		System.out.println(a / 10);
	}

}
